﻿angular.module('MyIndexModule', [])
	.controller("MyIndexCtrl", ['$scope', '$state', '$timeout', function($scope, $state, $timeout) {
//		var clickNumber = 0; //计算是否打开或者关闭
		//		var count = 0;
		var hb_money=1; //红包金额
		
		
		if(hb_money==''||hb_money==undefined){
			console.log(hb_money)
			$scope.showHb=false;
		}else{
			$scope.showHb=true;			
		}
		
		//谁发的红包
		$scope.popupName = '村二麻子';
		$scope.boy="白云";//新郎
		$scope.gril="黑土";//新娘
		
		$(function() {
			$(".gift_item")[0].style.border = "5px solid #feacad"; //设置礼物窗口打开时的边框
		});
	
		$scope.SetTimer = function() {
			$scope.$apply(function() {
				for(var i = 0; i < $('.Bar_box_TXT').length; i++) {
					if($($(".Bar_box_TXT")[i]).offset().top / $(window).height() < 0.77) {
						$($(".Bar_box_TXT")[i]).addClass("Bar_box_TXT1")
					} else {
						$($(".Bar_box_TXT")[i]).removeClass("Bar_box_TXT1")
					}

				}
			});
		};
		//每隔1秒刷新一次时间
		$scope.SetTimerInterval = setInterval($scope.SetTimer, 100);
		
		class index{
			
			constructor() 
			{
				this.hb_pw = '';
				this.hb_tips = ''; //判断答案后的处理
			
				this.isActive='';//用户头像位置样式
				
			}
			//谁跟谁的婚礼？
		skip() {
			$scope.upgrade($scope.count);
			$state.go("loveHouse", { wedOfName: "白云和黑土的请柬" })
		}
			//点击开启红包判读输入的答案是否正确。
		openMoney(){			
			if(hb_pw === $scope.popupName) {
				hb_tips = "已存入余额"; //判断答案后的处理
				$scope.hbBG = "images/index/popup/hb-2.png";
				isActive = false;
				$scope.hbPw = hb_money.toFixed(2);
			} else {
				$scope.hb_tips = '*答案错误'; //判断答案后的处理
			}
		};
		onTopHB() {
			$scope.openHb = true;
			$scope.hbBG = "images/index/popup/hb-1.png"; //发红包的用户的头像
			$scope.isActive = true;
			$scope.hbPw = "新郎的名字是什么？"; //问题		
		};	
		closeHB(){
			$scope.openHb = false;
		};
		DIYMsgS() {		
			$scope.sendMsgNum++;
			let myDate = new Date();
			let NewDate = myDate.getFullYear() + "-" + myDate.getYear() + "-" + myDate.getDate();
			let NewHours = myDate.getHours() + ":" + myDate.getMinutes();
			$scope.randomNum = parseInt(Math.random() * 13 + 1);
			if($scope.MyDIYMsg != undefined) {				
				$scope.MsgArray.push({
					userImg: $scope.userImg,
				userName: $scope.userName,
					randomNum: $scope.randomNum,
					txt: $scope.MyDIYMsg,
					isemoji_img: false
				})
				$scope.LHrecord.push({
					recordTime: NewDate,
					userImg: $scope.userImg,
				userName: $scope.userName,
					txt: $scope.MyDIYMsg,
					recordHours: NewHours,
					isRecord: true,
					isemoji_img: false
				});
				$scope.BarMsg.push({
					userName: $scope.userName,
					txt: $scope.MyDIYMsg,
					isemoji_img: false
				})
				$scope.isDanmaku = true;
				$('.input_diyMsg').val("");
			}			
		if($scope.sendMsgNum<4){
				$scope.upgrade(1);
			}
		
		};
		
		
		}
		$scope.index=new index();
		
	}])